package com.easyadmin.service;

import com.easyadmin.entity.dto.SessionUserDto;
import com.easyadmin.entity.po.SysAccount;
import com.easyadmin.entity.query.SysAccountQuery;
import com.easyadmin.entity.vo.PaginationResult;
import com.easyadmin.exception.BusinessException;

import javax.servlet.http.Cookie;
import java.util.List;


/**
 *
 * 账号信息 业务接口
 *
 */
public interface SysAccountService {

    /**
     * 根据条件查询列表
     */
    List<SysAccount> findListByParam(SysAccountQuery param);

    /**
     * 根据条件查询列表
     */
    Integer findCountByParam(SysAccountQuery param);

    /**
     * 分页查询
     */
    PaginationResult<SysAccount> findListByPage(SysAccountQuery param);

    /**
     * 新增
     */
    Integer add(SysAccount bean) throws BusinessException;

    /**
     * 批量新增
     */
    Integer addBatch(List<SysAccount> listBean);

    /**
     * 批量新增/修改
     */
    Integer addOrUpdateBatch(List<SysAccount> listBean);

    /**
     * 根据Phone修改
     */
    Integer updateByPhone(SysAccount bean, String phone);


    /**
     * 根据Phone删除
     */
    Integer deleteByPhone(String phone);


    /**
     * 根据Phone查询对象
     */
    SysAccount getSysAccountByPhone(String phone);


    /**
     * 根据UserId修改
     */
    Integer updateByUserId(SysAccount bean, Integer userId);


    /**
     * 根据UserId删除
     */
    Integer deleteByUserId(Integer userId);


    /**
     * 根据UserId查询对象
     */
    SysAccount getSysAccountByUserId(Integer userId);


    /**
     * 根据Account修改
     */
    Integer updateByAccount(SysAccount bean, String account);


    /**
     * 根据Account删除
     */
    Integer deleteByAccount(String account);


    /**
     * 根据Account查询对象
     */
    SysAccount getSysAccountByAccount(String account);

    /**
     * 保存账号
     * @param sysAccount
     */
    void saveSysAccount(SysAccount sysAccount) throws BusinessException;

    void updatePassword(Integer userId, String oldPassword, String password) throws BusinessException;

    SessionUserDto login(String account, String password, Boolean haveMd5) throws BusinessException;

    SessionUserDto autoLogin(Cookie[] cookies);
}